<!--20210304    zaq    创建vue文件-->
<!--20210511    zaq    设计界面以及数据格式-->

<template>
<!--发表说说-->
  <div class="insert_text">
<!--    表单-->
    <el-form ref="form" :model="form" label-width="100%"
             :inline="true"
    >
<!--      <el-form-item label="说说分组">-->
<!--        <el-select v-model="form.gId" placeholder="请选择分组"-->
<!--        >-->
<!--          <el-option-->
<!--              v-for="group in groups"-->
<!--              :key="group.gID"-->
<!--              :label="group.gName"-->
<!--              :value="group.gName"></el-option>-->
<!--        </el-select>-->
<!--      </el-form-item>-->
      <el-form-item style="width: 80%">
        <el-input
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 4}"
            style="width: 100%"
            placeholder="有话要说"
            v-model="form.tText"
            class="input-with-select"
        >
        </el-input>

      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-upload2" @click="submit" >发送</el-button>
      </el-form-item>

    </el-form>
  </div>
</template>

<script>
import {insert_16211} from "../../api";

export default {
  name: "Text",
  methods:{
    submit(){
      const _this=this
      //合法性检验
      if(_this.form.tText==null){
        _this.$message({
          type: 'error',
          message: '内容不能为空，请重新输入'
        });
      }else{
        var uId=sessionStorage.getItem("uId")
        var gId=sessionStorage.getItem("gId")
        var tgId=sessionStorage.getItem("tgId")
        console.log("u:"+uId+"  g:"+gId)
        var body={
          uid:uId,
          tgId:tgId,
          gId:gId,
          tText:_this.form.tText,
          tFId:-1,//父对象ID
          tFGid:-1,//父对象分组ID
          tFlag:0,//评论数
        }
        insert_16211(body).then(resp=>{
          if(resp.code>0){
            _this.$message({
              type: 'success',
              message: '发布说说成功'
            });
          }else{
            _this.$message({
              type: 'error',
              message: '发布说说失败:'+resp.note
            });
          }
        }).catch(err=>{
          _this.$message({
            type: 'error',
            message: '发布说说失败:'+err
          });
        })
      }

    }
  },
  data(){
    return {
      form:{
        tId:'1',
        tDate:'20210511',
        tTime:'8:00',
        tText:'',//内容
        tFId:'',//父对象ID
        tFGid:'',//父对象分组ID
        tFlag:'',//评论数
        gId:'a',//分组
        uId:'',//用户ID
      },
      groups:[
        {
          gID:'1',
          gName:'a',
          gText:'aa',
          gBeginTime:'20210511',
          gEndTime:'',
          gDefault:'',
          uId:'',//用户ID
          tgId:'',//模板ID
          delete:'',//
        },
        {
          gID:'2',
          gName:'b',
          gText:'bb',
          gBeginTime:'20210511',
          gEndTime:'',
          gDefault:'',
          uId:'',//用户ID
          tgId:'',//模板ID
          delete:'',//
        }
      ]
    }
  }
}
</script>

<style scoped>
.insert_text{
  text-align: left;
}
</style>